/* Doesnt' work. Why? */
//AjaxLab.Engine.Plugins.BaseCommands.callBaseMethod(this, 'registerCommands',[customCommands]);

/*
		Will it be better to use delegate and have users define their own method instead? lik
		this.registerCommandProcess(custoCommand, commandCallBack, commandCallBackContext);
		
		CMDUtil.js is avaiable for plug in classes to use. - this.Console
*/
	
Type.registerNamespace("AjaxLab.Engine.Plugins");
AjaxLab.Engine.Plugins.TimeLineTasks= function()
{
	var customCommands = "task|timeline";
	var instance = this;
	AjaxLab.Engine.Plugins.BaseCommands.initializeBase(this);
	this.registerCommands(customCommands);
	
	/* Implement the Plug In here */
	
	this.getImage = function(eventType)
	{
		var image = "";
		if(eventType.toUpperCase()=="MEETING")
		{
			image = "images/Icons/ShowGridlinesHS.png";
		}
		else if(eventType.toUpperCase()=="TASK")
		{
			image = "images/Icons/CheckBoxHS.png";
		}
		else if(eventType.toUpperCase()=="EMAIL")
		{
			image = "images/Icons/eps_closedHS.png";
		}
		else if(eventType.toUpperCase()=="HELPDESK")
		{
			image = "images/Icons/DialHS.png";
		}
		else if(eventType.toUpperCase()=="CONTACTS")
		{
			image = "images/Icons/Book_openHS.png";
		}
		else if(eventType.toUpperCase()=="NETWORK")
		{
			image = "images/Icons/server.ico";
		}
		else if(eventType.toUpperCase()=="DESIGN")
		{
			image = "images/Icons/ColorHS.png";
		}
		return image;
	}
	
	this.processCommands = function(inputtext) {
		
		var eventicon = "meeting";
		var taskname = "not specified";
		var taskdesc = "not specified";
		var startdate = "7/17/2006";
		var starttime = "10:00:00";
		
		var command     = inputtext.split("|");
		if(command[0]!=null)
		{
			var f_command = command[0].split(" ");
			if(f_command[0].toUpperCase() == "TASK" || f_command[0].toUpperCase() == "TIMELINE" )
			{
				if(f_command[1]!=null && f_command[1].toUpperCase() == "-ADD")
				{
					if(f_command[2]!=null)
					{
						eventicon = f_command[2];
						if(command[1]!=null)
						{
							taskname = command[1];
							if(command[2]!=null)
							{
								taskdesc = command[2];
								if(command[3]!=null)
								{
									startdate = command[3];
									if(command[4]!=null)
									{
										starttime = command[4];
										//alert(eventType +"/"+taskname+"/"+taskdesc+"/"+startdate+"/"+starttime);
										eventicon = this.getImage(eventicon);
										//alert(eventicon);
										eventSource.LoadEventComplete(startdate,starttime, null,null,null,null,false,taskname,taskdesc,null,null,eventicon,null,null);

									    instance.Console.newPrompt();
									}
									else{
									instance.Console.printToConsole(inputtext+" is not recognized as an internal or external command");
									}	
								}
								else{
								instance.Console.printToConsole(inputtext+" is not recognized as an internal or external command");
								}	
							}
							else{
								instance.Console.printToConsole(inputtext+" is not recognized as an internal or external command");
							}	
						}
						else{
							instance.Console.printToConsole(inputtext+" is not recognized as an internal or external command");
						}
					}	
					else{
				instance.Console.printToConsole(inputtext+" is not recognized as an internal or external command");
					}	
				}
				else{
				instance.Console.printToConsole(inputtext+" is not recognized as an internal or external command");
				}	
			}
			else{
				instance.Console.printToConsole(inputtext+" is not recognized as an internal or external command");
			}
		}
		else{
			instance.Console.printToConsole(inputtext+" is not recognized as an internal or external command");
		}
		
		
    }
}
AjaxLab.Engine.Plugins.TimeLineTasks.registerClass('AjaxLab.Engine.Plugins.TimeLineTasks', AjaxLab.Engine.Abstract.Commands);




